package com.zjeav.lingjiao.base.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import com.zjeav.lingjiao.R;
import com.zjeav.lingjiao.base.baseBean.Book;

public class BookAdapter extends BaseQuickAdapter<Book, BaseViewHolder> {
    private Context context;
    private int mType = 0;

    public BookAdapter(Context context) {
        super(R.layout.book_item);
        this.context = context;
    }

    public BookAdapter(Context context, int type) {
        super(R.layout.book_item);
        this.context = context;
        this.mType = type;
    }

    @Override
    protected void convert(com.chad.library.adapter.base.BaseViewHolder helper, Book item) {
        helper.setText(R.id.book_info_txt, item.getSubject());
        helper.setText(R.id.book_title_txt, item.getTitle());
        if (mType == 1) {
            helper.getView(R.id.money_txt).setVisibility(View.VISIBLE);
            helper.setText(R.id.money_txt, "￥ "+item.getPrice());
        }
        ImageView imageView = helper.getView(R.id.book_im);
        Glide.with(context)
                .load(item.getCover())
                .into(imageView);


    }
}